package com.magazine.bean.pages;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
/**
 * 翻页功能
 * @author zhugd
 */
@SuppressWarnings("unchecked")
public abstract class DataPageSupport extends ActionSupport {
	private DataPage dataPage = new DataPage();// 页面工具类，记载翻页信息
	abstract public List pageQueryList();
	public String doGoPage() throws Exception{
		this.setPages(pageQueryList());
		return SUCCESS;
	}
	//页面列表信息
	private List listPages = null;
	public void setPages(List list){
		this.listPages = list;
	}
	public List getPages(){
		return this.listPages;
	}
	// 当前�?
	public void setCurrPage(int iPage) {
		this.dataPage.setCurrPage(iPage);
	}
	public int getCurrPage() {
		return this.dataPage.getCurrPage();
	}
	// 前一�?
	public int getPrvPage() {
		return this.dataPage.getPrvPage();
	}
	// 后一�?
	public int getNextPage() {
		return this.dataPage.getNextPage();
	}
	//�?大页�?
	public int getMaxPage() {
		return this.dataPage.getAllPage();
	}
	//设置总记录数
	public void setAllPageSize(int iSize) {
		this.dataPage.setAllPageNumber(iSize);
	}
	public int getAllPageSize(){
		return this.dataPage.getAllPageNumber();
	}
	//单页展现的记录数
	public int getPageSize(){
		return this.dataPage.getPageNumber();
	}
	// 上层目录�?
	public void setParentPage(int iPage) {
		this.dataPage.setParentPage(iPage);
	}
	public int getParentPage() {
		return this.dataPage.getParentPage();
	}
	/**
	 * 上上级当前页�?
	 */
	private int iParent2Page = 0;
	public int getParent2Page(){
		return this.iParent2Page;
	}
	public void setParent2Page(int iPage){
		this.iParent2Page = iPage;
	}
	//是否换行
	public int getPageEnter(){
		return this.dataPage.getPageEnter()-1;
	}
	
	public void setPageNumber(int number){
		this.dataPage.setPageNumber(number);
	}
	public void setPageLevel(int level){
		this.dataPage.setPageLevel(level);
	}
	/**
	 * 返回是否换行
	 * @param index
	 * @return
	 */
	public boolean IsPageEnter(int index){
		int iEnter = this.dataPage.getPageEnter();
		if(((index+1)%iEnter)==0)
			return true;
		return false;
	}
}
